package com.atguigu.myrule;

import com.netflix.loadbalancer.IRule;
import com.netflix.loadbalancer.RandomRule;
import com.netflix.loadbalancer.RoundRobinRule;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @program: cloud2020
 * @description: 自定义负载均衡路由规则类,此类不能放在能被@ComponentScan扫描到的地方,即默认是springboot启动类所在包及其子包
 * @author: YuWenYi
 * @create: 2021-04-14 15:05
 **/
@Configuration
public class MySelfRule {

    @Bean
    public IRule roundSelfRule() {
        // 定义为随机
        return new RandomRule();
    }
}
